package com.swpu.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swpu.project.common.BaseResponse;
import com.swpu.project.mapper.NonHeavyMetalMapper;
import com.swpu.project.model.entity.NonHeavyMetal;
import com.swpu.project.service.INonHeavyMetalService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.swpu.project.util.AuthorityUtil.checkAuthority;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author swpuyanxiegroup1
 * @since 2024-07-29
 */
@Service
public class NonHeavyMetalServiceImpl extends ServiceImpl<NonHeavyMetalMapper, NonHeavyMetal> implements INonHeavyMetalService {

    @Override
    public BaseResponse queryData(String belongId) {
        List<NonHeavyMetal> list = lambdaQuery().eq(NonHeavyMetal::getBelong, belongId).
                select(NonHeavyMetal::getDataId,NonHeavyMetal::getData,NonHeavyMetal::getName).
                list();


        return BaseResponse.ok(list);
    }

    @Override
    public BaseResponse updateNonHeavyMetal(List<NonHeavyMetal> nonHeavyMetals, String blockNum) {
       if(!checkAuthority(blockNum))
            return BaseResponse.fail("您无权进行该操作或数据填写有误");




        return BaseResponse.iFSuccess(saveOrUpdateBatch(nonHeavyMetals));

    }



}
